package gameservice

import (
	"admin100/app/dao/gamedao"
	"admin100/library/define"
	"admin100/library/define/defErr"

	"github.com/gogf/gf/util/gconv"
)

var ServerData = &serverDataService{}

type serverDataService struct{}

//获取节点版本
func (s *serverDataService) GetNodeVersion(node string) int {
	gameDb := gamedao.NewServerDataDao(node)
	r, err := gameDb.Fields(
		gameDb.Columns.IntData).Where(
		gameDb.Columns.Id, 0).Value()
	defErr.IfPanic(err, define.RecordNodFound)
	if r == nil {
		return 0
	}

	return gconv.Int(r.Val())
}

//获取节点合服时间
func (s *serverDataService) GetMergeTime(node string) int {
	gameDb := gamedao.NewServerDataDao(node)
	r, err := gameDb.Fields(
		gameDb.Columns.IntData).Where(
		gameDb.Columns.Id, 6).Value()
	defErr.IfPanic(err, define.DataOptFail)
	if r == nil {
		return 0
	}

	return gconv.Int(r.Val())
}
